home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / cpp_libs / cool / cool.lha / ice / pisces / mkdepend / cppsetup.c < prev    next >
Encoding:
C/C++ Source or Header  |  1991-09-04  |  1.6 KB  |  101 lines

  1. /*
  2.  * $XConsortium: cppsetup.c,v 1.5 89/06/13 19:15:36 jim Exp $
  3.  */
  4. #include "def.h"
  5.  
  6. #ifdef    CPP
  7. /*
  8.  * This file is strictly for the sake of cpy.y and yylex.c (if
  9.  * you indeed have the source for cpp).
  10.  */
  11. #define IB 1
  12. #define SB 2
  13. #define NB 4
  14. #define CB 8
  15. #define QB 16
  16. #define WB 32
  17. #define SALT '#'
  18. #if pdp11 | vax | ns16000 | mc68000 | ibm032
  19. #define COFF 128
  20. #else
  21. #define COFF 0
  22. #endif
  23. /*
  24.  * These variables used by cpy.y and yylex.c
  25.  */
  26. extern char    *outp, *inp, *newp, *pend;
  27. extern char    *ptrtab;
  28. extern char    fastab[];
  29. extern char    slotab[];
  30.  
  31. /*
  32.  * cppsetup
  33.  */
  34. struct filepointer    *currentfile;
  35. struct inclist        *currentinc;
  36.  
  37. cppsetup(line, filep, inc)
  38.     register char    *line;
  39.     register struct filepointer    *filep;
  40.     register struct inclist        *inc;
  41. {
  42.     register char *p, savec;
  43.     static boolean setupdone = FALSE;
  44.     boolean    value;
  45.  
  46.     if (!setupdone) {
  47.         cpp_varsetup();
  48.         setupdone = TRUE;
  49.     }
  50.  
  51.     currentfile = filep;
  52.     currentinc = inc;
  53.     inp = newp = line;
  54.     for (p=newp; *p; p++)
  55.         ;
  56.  
  57.     /*
  58.      * put a newline back on the end, and set up pend, etc.
  59.      */
  60.     *p++ = '\n';
  61.     savec = *p;
  62.     *p = '\0';
  63.     pend = p;
  64.  
  65.     ptrtab = slotab+COFF;
  66.     *--inp = SALT; 
  67.     outp=inp; 
  68.     value = yyparse();
  69.     *p = savec;
  70.     return(value);
  71. }
  72.  
  73. struct symtab *lookup(symbol)
  74.     char    *symbol;
  75. {
  76.     static struct symtab    undefined;
  77.     struct symtab   *sp;
  78.  
  79.     sp = defined(symbol, currentinc);
  80.     if (sp == NULL) {
  81.         sp = &undefined;
  82.         sp->s_value = NULL;
  83.     }
  84.     return (sp);
  85. }
  86.  
  87. pperror(tag, x0,x1,x2,x3,x4)
  88.     int    tag,x0,x1,x2,x3,x4;
  89. {
  90.     do_log("\"%s\", line %d: ", currentinc->i_file, currentfile->f_line);
  91.     do_log(x0,x1,x2,x3,x4);
  92. }
  93.  
  94.  
  95. yyerror(s)
  96.     register char    *s;
  97. {
  98.     log_fatal("Fatal error: %s\n", s);
  99. }
  100. #endif /* CPP */
  101.